package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.activity.RetailLevelActivity;
import cn.xfdzx.android.apps.shop.bean.HomeRetailBeen;
import cn.xfdzx.android.apps.shop.util.Utils;

/**
 * @author gzk
 * @date 2020/3/28 0028
 * description：首页每日特价活动
 */
public class HomeDayViewHolder extends RecyclerView.ViewHolder {

    @BindView(R.id.tv_home_day_h_1)
    TextView tvHomeDayH1;//第一个的特价时间场
    @BindView(R.id.tv_home_day_h_2)
    TextView tvHomeDayH2;//第二个的特价时间场
    @BindView(R.id.tv_home_day_text_1)
    TextView tvHomeDayText1;//第一个的特价时间状态，分别为状态或者时间
    @BindView(R.id.tv_home_day_text_2)
    TextView tvHomeDayText2;//第二个的特价时间状态，分别为状态或者时间
    @BindView(R.id.iv_home_day_1)
    ImageView ivHomeDay1;//第一个图片
    @BindView(R.id.iv_home_day_2)
    ImageView ivHomeDay2;//第二个图片

    private Context mContext;

    public HomeDayViewHolder(Context mContext, View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);
        this.mContext = mContext;

    }

    public void setData(List<HomeRetailBeen.DataBean.IndexWholesaleCategoryBean> indexList) {
        tvHomeDayH1.setText(R.string.time_18);
        tvHomeDayText1.setText(R.string.time_1);
        tvHomeDayH2.setText(R.string.time_18);
        tvHomeDayText2.setText(R.string.snap_up_in);
        ivHomeDay1.setImageResource(R.drawable.image_home_day_1);
        ivHomeDay2.setImageResource(R.drawable.image_home_day_2);

        ivHomeDay1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Utils.isFastClick()){
                for (HomeRetailBeen.DataBean.IndexWholesaleCategoryBean bean:indexList){
                    if (bean.getName().equals("新鲜蔬菜")){
                        Intent intent = new Intent(mContext, RetailLevelActivity.class);
                        intent.putExtra("title_name", bean.getName());
                        intent.putExtra("type_id", bean.getId()+"");
                        mContext.startActivity(intent);
                    }
                }

            }}
        }); ivHomeDay2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Utils.isFastClick()){
                for (HomeRetailBeen.DataBean.IndexWholesaleCategoryBean bean:indexList){
                    if (bean.getName().equals("时令水果")){
                        Intent intent = new Intent(mContext, RetailLevelActivity.class);
                        intent.putExtra("title_name", bean.getName());
                        intent.putExtra("type_id", bean.getId()+"");
                        mContext.startActivity(intent);
                    }
                }
            }}
        });
    }
}
